package com.java.es;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.GetIndexResponse;

import java.io.IOException;

/**
 * @ClassNameEs_Client
 * @Description
 * @Author liufei
 * @Date2021/12/8 10:32
 * @Version V1.0
 **/
public class Es_Client_Index_Search {
    public static void main(String[] args) throws IOException {
        //创建es客户端
        RestHighLevelClient esClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost("localhost",9200,"http"))
        );
        //创建索引
        GetIndexRequest request = new GetIndexRequest("user");
        GetIndexResponse getIndexResponse = esClient.indices().get(request, RequestOptions.DEFAULT);

        System.out.println("索引操作:"+getIndexResponse.getAliases());
        System.out.println("索引操作:"+getIndexResponse.getMappings());
        System.out.println("索引操作:"+getIndexResponse.getSettings());
        //关闭es客户端
        esClient.close();
    }
}
